package com.siruier.boss.ui.activity.commom

import com.siruier.boss.api.core.launchUI
import com.siruier.boss.api.core.toData
import com.siruier.boss.api.mallApi
import com.siruier.boss.bean.BlTelRecharge
import com.siruier.boss.databinding.ActivityBaseRefreshBinding
import com.siruier.boss.databinding.ItemMyMessageBinding
import com.siruier.boss.databinding.ItemPrepaidRefillRecordBinding
import com.siruier.boss.ui.base.BaseActivity
import com.siruier.boss.ui.base.BaseRecyclerAdapter
import com.siruier.boss.ui.helper.RefreshHelper

class PrepaidRefillRecordActivity : BaseActivity<ActivityBaseRefreshBinding>() {

    private lateinit var mRefreshHelper: RefreshHelper<BlTelRecharge>
    private val mPrepaidRefillRecordAdapter = PrepaidRefillRecordAdapter()

    override fun initView() {
        vb.titleView.titleStr = "充值记录"
        mRefreshHelper = RefreshHelper(vb.refreshLayout, vb.recyclerView, mPrepaidRefillRecordAdapter) { onReload() }
        mRefreshHelper.onRefresh()
    }

    private fun onReload() {
        launchUI({ mallApi.rechargeList(mRefreshHelper.page).toData()?.records }, mRefreshHelper.handApiObserver())
    }

    class PrepaidRefillRecordAdapter : BaseRecyclerAdapter<ItemPrepaidRefillRecordBinding, BlTelRecharge>() {
        override fun onBindViewHolder(vb: ItemPrepaidRefillRecordBinding, bean: BlTelRecharge, position: Int) {
            vb.run {
                bean.run {
                    tvRemark.text = phone
                    tvAmount.text = cardNum
                    tvAddtime.text = addTime
                    tvReason.text = reason
//                    tvTitle.text = name
//                    txMsgDate.text = addTime
//                    tvContent.text = content
//                    tvIsRead.visibility = View.GONE
                }
            }
        }
    }

}
